1. Field of the Invention
The present invention relates to encoding apparatuses and methods for encoding video data, and in particular, to an encoding apparatus and method that uses different quantization matrices for quantization and inverse quantization, whereby, when quantization and inverse quantization are repeatedly performed, image-quality deterioration in video data can be prevented.
2. Description of the Related Art
In the field of video-data recording and reproduction in videocassette recorders and video servers for broadcasting stations and practical use, it has become common, with the establishment of compression encoding based on the moving picture experts group two (MPEG-2) standard, that video data compressed based on the MPEG-2 standard are recorded and reproduced.
FIG. 1 shows the structure of a general encoder 10 that performs compression encoding. As shown in FIG. 1, in an encoder 10, image signals are input to a scanning-conversion macroblock generator 11. The scanning-conversion macroblock generator 11 converts the units of the image signals from fields into frames, and generates the order of macroblocks having 16×16 pixels by performing conversion based on the order of scanning lines. An adder 12 adds, in units of 8×8 pixel blocks (DCT blocks) constituting the macroblocks, the signals in the macroblock units and prediction signals output from a motion compensator 21, and inputs the sums to a discrete cosine transform (DCT) unit 13.
The DCT unit 13 computes DCT coefficients by performing discrete cosine transform processing for each block. The DCT coefficients are input to a quantizer 14. By dividing each input DCT coefficient by the product of a quantization index signal output from a rate controller 17 and a predetermined quantization matrix, each coefficient is quantized. The quantization results are output from the quantizer 14, while being zigzag-scanned. The output quantized data are input to a variable length code (VLC) unit 15. After the data are transformed into variable length codes, they are output as a stream via an output buffer 16. The amount of the generated codes of the stream is input to the rate controller 17, and it computes quantization indices to be output to the quantizer 14.
For the generation (partial decoding) of prediction signals, the quantized data output from the quantizer 14 are inverse-quantized by an inverse quantizer 18. The inverse DCT of the inverse-quantized data is performed by an inverse DCT unit 19, and the obtained data are input to an adder 20. The adder 20 adds outputs from the inverse DCT unit 19 and motion compensation predicting signals output from a motion compensator 21, and inputs and stores the sums in the motion compensator 21. A motion predictor 22 generates motion vectors based on outputs from the scanning-conversion macroblock generator 11, and outputs them to the motion compensator 21. The motion compensator 21 generates, based on the motion vectors, motion compensation predicting signals for partially decoded image data.
The signals encoded (compressed) by the encoder 10 are decoded by a decoder 30 as shown in FIG. 2. In other words, the stream is input to a variable length decoder (inverse VLC unit) 32 via an input buffer 31. After decoding the input stream, the variable length decoder 32 outputs image signal components to an inverse quantizer 33, and outputs motion vectors to a motion compensator 37. The inverse quantizer 33 transforms the input image signal components into DCT coefficients in accordance with an inverse quantization matrix. An inverse DCT unit 34 implements inverse DCT of the DCT coefficients, and the motion compensator 37 generates prediction signals by performing motion compensation for the already decoded image signals in accordance with the motion vectors. Outputs from the inverse DCT unit 34 are input to an adder 35, and are added to the prediction signal output from the motion compensator 37, whereby decoding is performed. The decoded signals are output and stored in the motion compensator 37, and are output to a format converter 36. The format converter 36 converts the decoded signals in units of macroblocks into image signals in units of scanning lines.
In order that information on the quantization matrix used in the quantizer 14 may be used for inverse quantization by the inverse quantizer 33 in the decoder 30, the information is described in a stream quantized in the output stage of the quantizer 14. This is because in the MPEG standard, syntax for describing quantization matrices is defined. When the decoder 30 decodes the encoded stream, the inverse quantizer 33 performs inverse quantization by using the quantized matrix information described in codes. In other words, in general encoding and decoding based on the MPEG standard, the quantization matrices used by the quantization unit 14 and the inverse quantization matrices used by the inverse quantization 33 are completely the same.
In ordinary editing performed in broadcasting stations and video productions, a plurality of source video data are repeatedly processed by using editing processes such as synthesizing and special effects, whereby edited video data are generated. In other words, in order to generate edited video data, recording to and reproduction from a recording medium must be repeatedly performed. As a result, encoding by the encoder 10 and decoding by the decoder 30 are repeatedly performed. This accumulates image distortions caused by quantization errors generated in image quantization and inverse quantization, which may cause great image deterioration.
The reason that the image quality deteriorates due to noise accumulated with repeated implementation of the MPEG encoding and decoding is described below.
The concept of the ordinary quantizer 14 and the concept of the inverse quantizer 33 are simply described. Each of the quantized data output from the quantizer 14 is expressed by the following expression:Q_data=DCT_coefficient/(Q_coefficient×Q_step)  (1)where “Q_data” represents each of the quantized data output from the quantizer 14, “DCT_coefficient” represents a DCT coefficient that is output from the DCT unit 13 and that is supplied to the quantizer 14, “Q_coefficient” represents a quantization coefficient in the quantization matrix supplied to the quantizer 14, and “Q_step” represents the quantization step supplied from the rate controller 17 to the quantizer 14. In other words, each of the quantized data output from the quantizer 14 is a value obtained by dividing the DCT coefficient by the product of the quantization coefficient and the quantization step. For example, in the case where the product of the quantization coefficient and the quantization step is 100, the quantizer 14 outputs values divided by 100 as quantized data.
The inverse quantizer 33 in the decoder 30 performs processing, which is inverse to that performed by the quantizer 14, on the DCT coefficient supplied from the variable length decoder 32. A DCT coefficient “DCT_coefficient” output from the inverse quantizer 33 is expressed by the following expression:DCT_coefficient=Q_data×(Q_coefficient×Q_step)  (2)
In other words, the DCT coefficient “DCT_coefficient” is a value obtained by multiplying the DCT coefficient by the quantization coefficient and the quantization step. Referring to the above-described example, in the case where the product of the quantization coefficient and the quantization step is 100, the inverse quantizer 33 outputs values multiplied by 100 as DCT coefficients.
Although it may be said that the inverse quantization based on the expression (2) is a process for restoring the quantization performed based on the expression (1), complete restoration of 100 percent is not performed. This is because the figures after the decimal point in the data computed based on the expression (1) are canceled and not transmitted to the decoder 30. Therefore, errors generated between the quantization computation and the inverse quantization computation are included as noise in the decoded video data.
In encoding and decoding based on the MPEG standard, more encoding bits are assigned to noises having high spatial frequency than to video components having a plain video image. Thus, an encoded stream generated by the encoding has more noises than those of source video data. The main cause of image quality deterioration is that noises (called “mosquito noise”) having high frequency components increase.
Subsequently, the inverse quantizer 33 processes the encoded stream including the noises by using the inverse quantization based on the expression (2). The inverse quantizer 33 inverse-quantizes not only the video components of the encoded stream but also the noise components. Thus, also the noise components are restored, similarly to the video components. Obviously, the restored noise components are larger than the noise components included in the source video data before being encoded.
Accordingly, in repeated implementation of the encoding and decoding based on an ordinary MPEG standard, noises accumulate that are generated by computation errors occurring between the quantization and the inverse quantization, which causes image quality deterioration in the decoded video data. In addition, in the ordinary inverse quantization based on the MPEG standard, a problem occurs in that image quality deteriorates because not only video components included in the encoded stream, but also noise components are inverse-quantized.